package com.tac.controller.scm;

import com.github.pagehelper.PageInfo;
import com.tac.common.result.Result;
import com.tac.pojo.scm.Supplier;
import com.tac.service.scm.SupplierService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RequestMapping("/supplier")
@Api(tags = "供应链SCM--采购管理--供应商接口")
@CrossOrigin
@RestController
public class SupplierController {

    @Autowired
    private SupplierService supplierService;

    //查看供应商列表
    @GetMapping("/getList")
    @ApiOperation("查看供应商列表")
    public Result<PageInfo<Supplier>> getList(Integer pageNum, Integer pageSize, String supplierName, String contactPerson){
        return supplierService.getList(pageNum,pageSize,supplierName,contactPerson);
    }
    //修改供应商信息
    @ApiOperation("修改供应商信息")
    @PutMapping("/update")
    public Result update(@RequestBody Supplier supplier){
        return supplierService.update(supplier);
    }
    //删除供应商
    @ApiOperation("删除供应商")
    @DeleteMapping("/remove")
    public Result remove(@RequestBody List<Integer> ids){
        return supplierService.remove(ids);
    }
    //添加供应商
    @ApiOperation("添加供应商")
    @PostMapping("/save")
    public Result save(@RequestBody Supplier supplier){
        return supplierService.save(supplier);
    }

    //管理员审核
    @ApiOperation("管理员审核")
    @PutMapping("/updateExamine")
    public Result updateExamine(@RequestBody Supplier supplier){
        return supplierService.updateExamine(supplier);
    }
}
